package houtaiSevlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Model.Shangpin;
import houtaiDao.ShangpinDaoImpl;
import houtaiDao.ShangpingDao;

/**
 * Servlet implementation class selectOne
 */
public class selectOne extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public selectOne() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("bianhao");
		int bianhao = Integer.parseInt(id);
		ShangpingDao sp = new ShangpinDaoImpl();
		Shangpin shang =  sp.selOne(bianhao);
		HttpSession session = request.getSession();
		session.setAttribute("shang", shang);
		response.sendRedirect("update.jsp");
	
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
